/// <reference path="../../Resources/js/jquery/jquery.debug.js" />
/// <reference name="MicrosoftAjax.debug.js" />

Type.registerNamespace("BM");

// FileUploadValueHandler object

BM.FileUploadValueHandler = function(leafItem) {
    BM.FileUploadValueHandler.initializeBase(this, [leafItem]);
}

BM.FileUploadValueHandler.prototype = {

    getFileUploadLabel: function() {
        /// <returns type="jQuery">
        /// the file upload label jQuery array
        /// </returns>
        return $(this.getLeafNode()).children('.FileUploadLabel');

    },

    getHiddenInput: function() {
        /// <returns domElement="true" >
        /// the hidden input for keeping the data
        /// </returns>
        return $(this.getLeafNode()).children('.HiddenInput')[0];

    },

    getEditModeValue: function() {
        return this.getHiddenInput().value;
    },

    setEditModeValue: function(value) {        
        this.getHiddenInput().value = value;
        this.getFileUploadLabel().hide();
        this.leafItem.raiseChanged();
    },

    onchange: function(handler) {
        this.setValue(this.getControlValue());
        BM.FileUploadValueHandler.callBaseMethod(this, 'onchange', [handler]);
    }
}

BM.ValueHandler['FileUploadValueHandler'] = BM.FileUploadValueHandler;
BM.FileUploadValueHandler.registerClass("BM.FileUploadValueHandler", BM.ValueHandler);